#include "dlgbasedqt.h"

#include "earthquake_global.h"

DlgBasedQt::DlgBasedQt():
    m_parent(0),
    m_ui(0),
    m_isDefault(true)
{
}

int DlgBasedQt::dlgSetParent(QWidget *parent)
{
    m_parent = parent;
}

QWidget *DlgBasedQt::dlgGetParent( void ) const
{
    return m_parent;
}

void DlgBasedQt::installDlg (QDialog *ui, const string &title)
{
    m_isDefault = false;
    m_ui = ui;
    m_ui->setWindowTitle(QSTR(title));
}

int DlgBasedQt::dlgExec ( void )
{
    // Se non ho istallato il dialogo allora ne creo uno di default
    if ( m_isDefault )
    {
        m_ui = new QMessageBox(
                    QMessageBox::Information,
                    QSTR(buildDlgTitle()),
                    tr("Non esiste una finestra per il modulo !!!"),
                    QMessageBox::Cancel|QMessageBox::Ok
                    );
    }
    return m_ui->exec();
}

void DlgBasedQt::dlgDelete ( void )
{
    if ( !m_isDefault )
        delete m_ui;
}


